home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 21
/
CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso
/
CUCD
/
Magazine
/
C_Tutorial
/
Part-9
/
wb0
/
toolwin.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-10-27
|
2KB
|
80 lines
#include "toolwin.h"
#include "gadgets.h"
#include "menu.h"
#include "screen.h"
#include<intuition/screens.h>
#include<stdio.h>
#include<clib/gadtools_protos.h>
#include<clib/intuition_protos.h>
/* Global record of our tool window */
struct Window* toolwin = NULL;
int openToolWin()
{
/* Extra protection -- only open if not already open */
if(toolwin == NULL)
{
struct Screen* scr = getScreen();
struct Menu* menu = getMenuStrip();
/* The minimal height of our tool window */
int h = gadgetHeight() + scr->WBorTop + (scr->Font->ta_YSize + 1) + scr->WBorBottom;
/* Open our tool window */
if(toolwin = OpenWindowTags(NULL,
WA_Left, 0,
WA_Top, scr->Height - h,
/* Make the window sit in the bottom of the screen */
WA_Width, scr->Width,
WA_Height, h,
WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR,
WA_IDCMP, IDCMP_CLOSEWINDOW | BUTTONIDCMP | IDCMP_REFRESHWINDOW | IDCMP_MENUPICK,
WA_Gadgets, getGadgets(),
WA_CustomScreen, scr,
WA_Title, "Tools",
TAG_DONE, 0))
{
/* Attach menu strip to tool window, as well */
if(SetMenuStrip(toolwin, menu))
{
/* Let GadTools refresh its bits of the tool window */
GT_RefreshWindow(toolwin, NULL);
return TRUE;
}
else
printf("Error: could not attach menus to tool window\n");
}
else
printf("Error: could not open tool window\n");
}
else
{
printf("Warning: tool window already open\n");
/* Only a warning, so don't return NULL */
return TRUE;
}
return FALSE;
}
void closeToolWin()
{
if(toolwin)
{
ClearMenuStrip(toolwin);
CloseWindow(toolwin);
toolwin = NULL;
}
}
struct Window* getToolWin()
{
return toolwin;
}
ULONG getToolSig()
{
return toolwin ? 1L << toolwin->UserPort->mp_SigBit : 0L;
}